home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / V2MISC / CSDPMI1S.ZIP / SRC / CWSDPMI / XMS.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-12-16  |  2.2 KB  |  127 lines

  1. ; Copyright (c) 1994 CW Sandmann (sandmann@clio.rice.edu)
  2.     title    xms
  3.     include    segdefs.inc
  4.  
  5.     start_data16
  6.  
  7. xms_entry    label    dword
  8.     dd    xms_spoof
  9.  
  10. ;noxmsmsg    label    byte
  11. ;    db    'No XMS?',13,10,'$'
  12.  
  13.     end_data16
  14.  
  15. ;------------------------------------------------------------------------
  16.  
  17.     start_code16
  18.  
  19. ; int xms_installed(void);
  20.     public    _xms_installed
  21. _xms_installed    proc    near
  22.     mov    ax,04300h
  23.     int    02fH
  24.     cmp    al,080h
  25.     je    short present
  26.     xor    ax,ax
  27.     ret
  28. present:
  29.     mov    ax,04310h
  30.     int    02fh
  31.     mov    word ptr xms_entry,bx
  32.     mov    word ptr (xms_entry+2),es
  33.     mov    ax,1
  34.     ret
  35. _xms_installed    endp
  36.  
  37. ; A dummy routine called only if routines are called out of order
  38. xms_spoof    proc    far
  39. ;    mov    dx,offset noxmsmsg
  40. ;    mov    ah,9
  41. ;    int    21h
  42.     mov    ax,4c01h
  43.     int    21h
  44. xms_spoof    endp
  45.  
  46. ; int xms_query_extended_memory(void) - return largest free block
  47.     public    _xms_query_extended_memory
  48. _xms_query_extended_memory    proc    near
  49.     mov    ah,08H
  50.     jmp    short no_arg_common
  51. _xms_query_extended_memory    endp
  52.  
  53. ; int xms_local_enable_a20(void)
  54.     public    _xms_local_enable_a20
  55. _xms_local_enable_a20    proc    near
  56.     mov    ah,05H
  57.     jmp    short no_arg_common
  58. _xms_local_enable_a20    endp
  59.  
  60. ; int xms_local_disable_a20(void)
  61.     public    _xms_local_disable_a20
  62. _xms_local_disable_a20    proc    near
  63.     mov    ah,06H
  64.     jmp    short no_arg_common
  65. _xms_local_disable_a20    endp
  66.  
  67. ; int xms_emb_free(short handle);
  68.     public    _xms_emb_free
  69. _xms_emb_free    proc    near
  70.     mov    ah,00aH
  71. handle_common:
  72.     push    bp
  73.     mov    bp,sp
  74.     mov    dx,[bp+4]
  75.     pop    bp
  76. no_arg_common:
  77.     call    [xms_entry]
  78.     ret
  79. _xms_emb_free    endp
  80.  
  81. ; int xms_unlock_emb(short handle);
  82.     public    _xms_lock_emb
  83. _xms_unlock_emb    proc    near
  84.     mov    ah,00dH
  85.     jmp    short handle_common
  86. _xms_unlock_emb    endp
  87.  
  88. ; ulong xms_lock_emb(short handle);
  89.     public    _xms_unlock_emb
  90. _xms_lock_emb    proc    near
  91.     push    bp
  92.     mov    bp,sp
  93.     mov    ah,00cH
  94.     mov    dx,[bp+4]
  95.      pop    bp
  96.     call    [xms_entry]
  97.     or    ax,ax
  98.     je    short lock_failed
  99.     mov    ax,bx
  100.     ret
  101. lock_failed:
  102.     mov    dx,ax
  103.      ret
  104. _xms_lock_emb    endp
  105.  
  106. ; int xms_emb_allocate(ushort size);
  107.     public    _xms_emb_allocate
  108. _xms_emb_allocate    proc    near
  109.     push    bp
  110.     mov    bp,sp
  111.     mov    ah,09H
  112.     mov    dx,[bp+4]
  113.     pop    bp
  114.     call    [xms_entry]
  115.     or    ax,ax
  116.     je    short alloc_failed
  117.     xchg    ax,dx
  118.     ret
  119. alloc_failed:
  120.     mov    ax,-1
  121.     ret
  122. _xms_emb_allocate    endp
  123.  
  124.     end_code16
  125.  
  126.     end
  127.